package com.yanqu.road.entity.autodata;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AutoUserDataClazzInfo {
    private Map<Field, List<MethodHandle>> fieldMethodHandleMap = new HashMap<>();
    private String updateSql;
    private String insertSql;
    private String tableName;
    private List<Field> fields;
    private List<Field> keyList;
    private Constructor<?> constructor;

    public Map<Field, List<MethodHandle>> getFieldMethodHandleMap() {
        return fieldMethodHandleMap;
    }

    public void setFieldMethodHandleMap(Map<Field, List<MethodHandle>> fieldMethodHandleMap) {
        this.fieldMethodHandleMap = fieldMethodHandleMap;
    }

    public String getUpdateSql() {
        return updateSql;
    }

    public void setUpdateSql(String updateSql) {
        this.updateSql = updateSql;
    }

    public String getInsertSql() {
        return insertSql;
    }

    public void setInsertSql(String insertSql) {
        this.insertSql = insertSql;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public List<Field> getKeyList() {
        return keyList;
    }

    public void setKeyList(List<Field> keyList) {
        this.keyList = keyList;
    }

    public MethodHandle findGetterHandle(Field field) {
        return fieldMethodHandleMap.get(field).get(0);
    }

    public MethodHandle findSetterHandle(Field field) {
        return fieldMethodHandleMap.get(field).get(1);
    }

    public Constructor<?> getConstructor() {
        return constructor;
    }

    public void setConstructor(Constructor<?> constructor) {
        this.constructor = constructor;
    }

    public List<Field> getFields() {
        return fields;
    }

    public void setFields(List<Field> fields) {
        this.fields = fields;
    }
}
